<html>
<head>
	<title>Excersise 10</title>
	<link href="styles/js-console.css" rel="stylesheet" />
</head>
<body>
	<div id="js-console"></div>
	<script src="scripts/js-console.js"></script>
	<script>
	function CountSubst(text)
	{
	var text = text;
	var lowText = text.toLowerCase();
	var words = new Array();
	var palindomes = new Array();
	var i, j, wordBeg, wordEnd;
	var marker;
	var tempCount;
	lowText = lowText.replace(". ", " ").replace("! ", " ").replace("?", " ").replace(", ", " ");
	words = lowText.split(" ");
	jsConsole.writeLine(lowText);	
	for (i=0;i<words.length;i++)		
	{
		marker = 0;
		wordBeg = 0;
		wordEnd = words[i].length-1;
		if((words[i].length%2)!=0)
		{
			tempCount = ((words[i].length/2)-0.5);
		}
		else
		{
			tempCount = (words[i].length/2);
		}				
		for(j=0;j<tempCount;j++)
		{
			if ((words[i].charAt(wordBeg))==(words[i].charAt(wordEnd)))
			{
				marker++
			}
			wordBeg++;
			wordEnd--;
		}	
		if (marker>((words[i].length/2)-1))
		{
			palindomes.push(words[i]);
		}
	}		
	jsConsole.writeLine();
	jsConsole.write("palindomes in this current text are: ");	
	for(i=0;i<palindomes.length;i++)
	{
		jsConsole.write(palindomes[i] + " ");	
	}	
	}
	var text = "else We are assa ara living in an yellow lammal submarine. We don't have anything else and exe Inside the submarine is very tight, so we are drinking all the day! We will move out of it in five days";
	CountSubst(text);
	</script>
</body>
</html>
